using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Razor.TagHelpers;
using NPOI.HPSF;
using System;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;

namespace ReaWTM.LayuiHelper
{
	[HtmlTargetElement("wt:images-rea")]
	public class ImagesTagHelper : BaseTag
	{

		public string Title { get; set; }
		public string Id { get; set; }
		public override void Process(TagHelperContext context, TagHelperOutput output)
		{
			output.TagName = "div";
			output.TagMode = TagMode.StartTagAndEndTag;
			if (string.IsNullOrWhiteSpace(Id))
			{
				Id = $"wtImgDiv_{Guid.NewGuid():N}";
			}
			output.Attributes.Add("id", Id);

			output.PostElement.AppendHtml($@"<script>wtm.imgs_Render({{id:'{Id}'}})</script>");
		}

	}
}
